package com.wmd.core.util;

import com.wmd.core.exceptions.MyException;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Simple to Introduction
 *
 * @projectName:DocumentLibrary
 * @packageName:com.wmd.core.util
 * @className:CharacterUtils
 * @Description:[一句话描述该类的功能]
 * @Author:luyincheng
 * @CreateDate:2021/5/18 17:57
 * @blog:[方法具体上行/下行参数文档]
 */
public class CharacterUtils {
    /**
     * 字符串是否包含中文
     *
     * @param str 待校验字符串
     * @return true 包含中文字符 false 不包含中文字符
     */
    public static boolean isContainChinese(String str)  {

        if (StringUtil.isEmpty(str)) {
            return false;
        }
        Pattern p = Pattern.compile("[\u4E00-\u9FA5|\\！|\\，|\\。|\\（|\\）|\\《|\\》|\\“|\\”|\\？|\\：|\\；|\\【|\\】]");
        Matcher m = p.matcher(str);
        if (m.find()) {
            return true;
        }
        return false;
    }

    public static boolean isNumeric(String str){
        if(str==null||str.length()==0){
            return false;
        }

        Pattern pattern = Pattern.compile("[0-9]*");

        return pattern.matcher(str).matches();

    }
}
